import React from 'react';
import { Redirect, ConnectProps, connect, UserModelState } from 'umi';

interface SecurityLayoutProps extends ConnectProps {
    user: UserModelState;
    loading: boolean;
}
const SecurityLayout: React.FC<SecurityLayoutProps> = ({ user, children }) => {
    return (
        <>
            {user.userid && children}
            {!user.userid && <Redirect to="/login" />}
        </>
    );
};

export default connect(({ user }: { user: UserModelState }) => ({
    user,
}))(SecurityLayout);
